<?php
/*************************************************************************

  $Id: IclearConfig.php 249 2009-06-16 06:44:07Z dis $

  iclear payment system - because secure is simply secure
  http://www.iclear.de

  Copyright (c) 2001 - 2009 iclear

  Released under the GNU General Public License

************************************************************************

                    All rights reserved.

  This program is free software licensed under the GNU General Public License (GPL).

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  USA

*************************************************************************/

  if(!defined('IC_SEC')) {
    die('No external calls allowed!');
  }
  
  if(stristr(PHP_OS, 'WIN')) {
  	define('IC_DS', '\\');
  } else {
    define('IC_DS', '/');
  }
  
  function icLoadConfig($name = '', $buildArray = false) {
  	$rv = false;
  	$path = dirname(__FILE__) . IC_DS . $name . '.ini';
  	if(file_exists($path)) {
		  foreach(parse_ini_file($path) AS $key => $val) {
		    define($key, $val);
		    if($buildArray) {
          $keys[] = $key;
          $search[] = '/\b' . $key . '\b/';
          $replace[] = $val;
		    }
		  }
		  if($buildArray) {
		  	$rv = array('keys' => $keys, 'search' => $search, 'replace' => $replace);
		  }
  	}
  	return $rv;
  }

  define('IC_CONFIG_VERSION', '$Id: IclearConfig.php 249 2009-06-16 06:44:07Z dis $');
  
  // IC soap 1.1 compliance
  define('IC_WSDL_VERSION', '1.1');
  
  define('IC_URI_BASE', 'http://www.iclear.de/');

  icLoadConfig('IclearConfig');
  
  if( defined('IC_DEBUG_DISPLAY_ERRORS') && IC_DEBUG_DISPLAY_ERRORS ) {
  	function_exists('error_reporting') && error_reporting(E_ALL);
  	function_exists('ini_set') && ini_set('display_errors', 1);
  }
  
  // Patch 2 circumvent usage of constants in ini files under PHP4
  // endpoint WSDL declaration files
	define('IC_WSDL_ORDER', 'ICOrderServices-' . IC_WSDL_VERSION . '.wsdl');
	define('IC_WSDL_USER', 'ICUserServices.wsdl');
  
  define('IC_URI_ORDER', IC_URI_BASE . IC_WSDL_ORDER);
  define('IC_URI_USER', IC_URI_BASE . IC_WSDL_USER);
  
  global $icSoapVarMap;
  $icSoapVarMap = icLoadConfig('IclearSOAP.' . IC_WSDL_VERSION, true);
  
  /**
   * Internal constants follows
   *
   */

  define('IC_URI_DEBUG_ORDER', 'http://api.iclear.de/EndpointDebugger/xmlbuytool-' . IC_WSDL_VERSION . '.php?wsdl');
  
  // this const is used 4 alternative endpoints, used by IclearSOAP extension
  define('IC_LOCAL_SOAP_ENDPOINT', '');
  define('IC_VERIFY_LOCAL_ENDPOINT', true);

  define('TABLE_IC_ORDERS', 'orders_iclear');
  define('IC_TABLE_ORDERS', 'iclear');

// ORDER STATES
  define('IC_ORDER_OPEN', -1);
  define('IC_ORDER_OK', 0);
  define('IC_ORDER_WAIT', 1);
  define('IC_ORDER_CANCEL', 2);
  
// error codes
  define('IC_ERROR_NO_SESSIONID', 101);
  define('IC_ERROR_NO_BASKETID', 102);
  define('IC_ERROR_ZERO_BASKET_VALUE', 103);
  define('IC_ERROR_BASKET_CANCELLED', 104);
  define('IC_ERROR_BASKET_ACCEPTED', 105);
  define('IC_ERROR_MAX_BASKET_DELTA_EXCEEDED', 106);
  define('IC_ERROR_NO_WAITING_BASKET', 107);
  define('IC_ERROR_WAITING_BASKET_NOT_IN_SHOP', 108);
  define('IC_ERROR_BASKET_MISMATCH', 109);
  define('IC_ERROR_MALFORMED_ICLEAR_RESULT', 110);
  define('IC_ERROR_UNKNOWN_ICLEAR_STATE', 111);
  define('IC_ERROR_BASKET_NOT_PROCESSED', 112);
  define('IC_ERROR_ORDER_NOT_FOUND_IN_SHOP', 113);
  define('IC_ERROR_ORDER_NOT_IN_WAITING_STATE', 114);
  define('IC_ERROR_ORDER_CANCEL_FAILED', 115);
  define('IC_ERROR_BASKET_WAITING', 116);
  define('IC_ERROR_BASKET_NOT_PROCESSED', 117);
  
  define('IC_ERROR_UNKNOWN_LOCAL_STATE', 900);
  
?>